cmake_minimum_required(VERSION 3.5)
project(targer_tracker)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Ofast -DNDEBUG -Wno-deprecated-declarations")
# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(geographic_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_sensor_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(image_transport REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(mavros_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(yolo_detect_message REQUIRED)
find_package(client_interfaces REQUIRED)


# Include directories
include_directories(
  include
  include/targer_tracker
  ${tf2_INCLUDE_DIRS}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

# Define the library
add_library(target_tracker 
  src/target_tracker.cpp
)

# Link libraries
target_link_libraries(target_tracker 
  ${EIGEN3_LIBRARIES}  # 使用 ${EIGEN3_LIBRARIES}
  ${tf2_LIBRARIES}
)

ament_target_dependencies(target_tracker
  cv_bridge
  yolo_detect_message
  rclcpp
  sensor_msgs
  std_msgs
  image_transport
  mavros_msgs
  client_interfaces
  geometry_msgs
  nav_msgs
)

# Define the executable
add_executable(target_tracker_node
  src/target_tracker_node.cpp)

target_link_libraries(target_tracker_node target_tracker)

ament_target_dependencies(target_tracker_node 
  cv_bridge
  yolo_detect_message
  rclcpp
  sensor_msgs
  std_msgs
  image_transport
  mavros_msgs
  client_interfaces
  geometry_msgs
  nav_msgs
)

# Install rules
install(TARGETS target_tracker_node target_tracker
  RUNTIME DESTINATION lib/${PROJECT_NAME}
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
)

install(DIRECTORY launch config DESTINATION share/${PROJECT_NAME})

ament_package()
